package e3dds

import (
	"gitee.com/ameise84/e3dds/internal/help"
	"gitee.com/ameise84/e3utils/str_conv"
)

func newServiceVirtual(e service, virtualID uint64) *virtual {
	return &virtual{
		entity:    e.(*entity),
		virtualID: virtualID,
	}
}

type virtual struct {
	*entity
	virtualID uint64
}

func (ts *virtual) isVirtualService() bool {
	return true
}

func (ts *virtual) LoadBalancerID() uint64 {
	return help.Hash16(ts.getSessionID())
}

func (ts *virtual) getSessionID() string {
	return str_conv.ToString(ts.virtualID) + ":" + ts.entity.getSessionID()
}
